import java.lang._

import org.apache.spark.{SparkConf, SparkContext}

/**
  * Created by Administrator on 2016/3/20.
  */
object SougouTest {

  val conf = new SparkConf()
    .setAppName("SougouTest")
    .setMaster("local")

  val sc = new SparkContext(conf)

  def main(args: Array[String]) {
    test()
    sc.stop()
  }

  def test() = {
    val lines = sc.textFile("file:///D:/SogouQ.sample")
    lines.map(_.split("\\s")).map(x => (x(1), 1)).reduceByKey(_ + _)
      .map(x => (x._2, x._1)).sortByKey(Boolean.FALSE).map(x => (x._2, x._1))
      .collect().foreach(println)
  }

}
